<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class CustomerInfo extends Model
{
    const SEX_MAN = 1;

    const SEX_WOMAN = 0;

    public static $SEX = [
        self::SEX_MAN => '男',
        self::SEX_WOMAN => '女'
    ];

    protected $table = 'customer_infos';

    protected $fillable = [
    	'header',
    	'name',
    	'sex',
    	'customer_id',
        'integration'
    ];

    protected $appends = [
        'sex_desc'
    ];


    public function getSexDescAttribute(){
        if(array_key_exists('sex',$this->attributes)){
            return $this->attributes['sex_desc'] = self::$SEX[$this->attributes['sex']];
        }
    }


    public function customer(){
    	return $this->hasOne('App\Models\Customer');
    }
}
